#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

const int MOD = 1000000007;

using namespace std;

typedef pair<int,int> pii;
#define vt first
#define vs second

pii bus[100100];

class BinTree
{
    int *c;
    int n;
    public:
    BinTree(int n)
    {
        this->n = n;
        c = new int[n+1];
        fill(c,c+n+1,0);
    }
    inline int LowBit(int pos)
    {
        return pos&(-pos);
    }
    void Insert(int pos,int val)
    {

        while(pos<=n)
        {
           // printf("ins pos = %d\n",pos);
            c[pos] = (c[pos]+val)%MOD;
            pos += LowBit(pos);
        }
    }
    int Query(int lb,int rb)
    {
      //  puts("que");
        int ans = 0;
        if(lb!=1) ans = Query(1,rb) - Query(1,lb-1);
        else
        {
            while(rb>=1)
            {
                ans = (ans + c[rb]) % MOD;
                rb -= LowBit(rb);
            }
        }
        if(ans<0) ans+=MOD;
        return ans;
    }
};

int main()
{
    map<int,int> mp;
    int n,m;
    cin>>n>>m;
    mp[0] = 0;
    mp[n] = 0;
    REP(i,m)
    {
        scanf("%d%d",&bus[i].vs,&bus[i].vt);
        mp[bus[i].vs] = 0;
        mp[bus[i].vt] = 0;
    }
    int cnt = 1;
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();++it)
    {
        it->second = cnt++;
    }
    REP(i,m) bus[i].vs = mp[bus[i].vs],bus[i].vt = mp[bus[i].vt];
    sort(bus,bus+m);
    BinTree bt(mp.size());
    bt.Insert(1,1);
    REP(i,m)
    {
        //printf("%d\n",i);
        int vs = bus[i].vs;
        int vt = bus[i].vt;
        int t = bt.Query(vs,vt-1);
        bt.Insert(vt,t);
    }
    int t = mp[n];
    cout<<bt.Query(t,t)<<endl;
	return 0;
}
